Note that the code above was inside a class with a contained 'lora' object. This will work better with your code snippet: for index in range(0,8): lora.remove_channel(index) for index in range(16,65): lora.remove_channel(index) for index in range(65,72): lora.remove_channel(index)